import React  , { useState } from 'react'
import pubsub from 'pubsub-js'


export default function Gege() {
  const [car , setCar] = useState("奥迪A6L")  

  const changeCarHandle = () => {
    setCar("一手雅迪");
    //当换车以后发布订阅
    pubsub.publish("qiche", "一手雅迪")
  }

  return (
    <div>
        <h1>我是哥哥,我开的车是{car}</h1>
        <button onClick={changeCarHandle}>哥哥赚大钱了要换车换车</button>
    </div>
  )
}
